home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!russells
- From: russells@netcom.com (Russell Salsbury)
- Subject: Re: Question-how print time from unix
- Message-ID: <russellsDpDstt.7KL@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <4jahpf$dpp@cloner2.ix.netcom.com>
- Date: Fri, 5 Apr 1996 08:56:17 GMT
- Sender: russells@netcom3.netcom.com
-
- martypro@ix.netcom.com (Marty) writes:
-
- >Ok here is a dumb question I'm sure:
-
- >Below is the relevant code I am using to input the time into a structure
- >element and can't find the appropriate conversion character to use with
- >printf to print it, that is if that is how you print it. Any help you
- >can give me will be greatly appreciated.
-
- >struct queue
- > {char name[MAX1];
- > time_t time_in;
- > int priority;
- > }customer[MAX2];
-
- >customer[inctr].time_in=time(NULL);
-
- use ctime.
-
- #include <stdio.h>
- #include <time.h>
-
- int main()
- {
- time_t tm;
- time(&tm);
- printf("Current time: %s", ctime(&tm)); /* ctime string has \n */
- return 0;
- }
-
- Ryan russells@netcom.com
-